local skel = fk.CreateSkill {
  name = "lb__huqiu",
}

Fk:loadTranslationTable {
  ["lb__huqiu"] = "互囚",
  --[":lb__huqiu"] = "出牌阶段限一次，你可以与一名其他角色互相视为对对方使用一张<a href=':mobile__enemy_at_the_gates'>【兵临城下】</a>。",
  --10.3
  --[":lb__huqiu"] = "弃牌阶段开始时，你可以与一名其他角色互相视为对对方使用一张<a href=':mobile__enemy_at_the_gates'>【兵临城下】</a>。",
  --10.25
  [":lb__huqiu"] = "弃牌阶段开始时，你可以与一名其他角色互相视为对对方使用一张<a href=':mobile__enemy_at_the_gates'>【兵临城下】</a>，你因此使用的非普通【杀】不可被响应。",

  ["#lb__huqiu"] = "互囚：你可以与一名其他角色互相视为对对方使用一张【兵临城下】",

  ["$lb__huqiu1"] = "听，那风暴的喧响在呼唤。",
  ["$lb__huqiu2"] = "献上一曲锋利的挽歌。",
}
--[[
skel:addEffect("active", {
  anim_type = "offensive",
  prompt = "#lb__huqiu",
  can_use = function(self, player)
    return player:usedSkillTimes("lb__huqiu", Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected, selected_cards, card, extra_data)
    return #selected == 0 and to_select ~= player and
    player:canUseTo(Fk:cloneCard("mobile__enemy_at_the_gates"), to_select)
  end,
  feasible = function(self, player, selected, selected_cards, card)
    return #selected == 1
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local to = effect.tos[1]
    room:useVirtualCard("mobile__enemy_at_the_gates", nil, player, to, skel.name)
    room:useVirtualCard("mobile__enemy_at_the_gates", nil, to, player, skel.name)
  end,
})
--]]
skel:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and player.phase == Player.Discard
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local use = room:askToUseVirtualCard(player, {
      name = "mobile__enemy_at_the_gates",
      skill_name = skel.name,
      prompt = "#lb__huqiu",
      cancelable = true,
      skip = true,
    })
    if use then
      event:setCostData(self, {use = use})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local use = event:getCostData(self).use ---@type UseCardDataSpec
    local to = use.tos[1]
    use.card.skill = Fk.skills["lb_huqiu__enemy_at_the_gates_skill"]
    use.extra_data = use.extra_data or {}
    ---@param slash_use UseCardDataSpec 兵临城下使用的杀
    local enemy_at_the_gates_slash_func = function (slash_use)
      slash_use.extra_data = slash_use.extra_data or {}
      slash_use.extra_data.lb__huqiu = player.id
    end
    use.extra_data.enemy_at_the_gates_slash_func = enemy_at_the_gates_slash_func
    room:useCard(use)
    room:useVirtualCard("mobile__enemy_at_the_gates", nil, to, player, skel.name)
  end,
})

skel:addEffect(fk.CardUsing, {
  anim_type = "offensive",
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) 
    and data.extra_data and data.extra_data.lb__huqiu == player.id
    and data.card.trueName == "slash" and data.card.name ~= "slash"
  end,
  on_use = function(self, event, target, player, data)
    data.disresponsiveList = player.room.players
  end,
})

return skel